const HtmlWebpackPlugin = require('html-webpack-plugin')


/**
 * 页面配置
 */
const pageList = [
    {
        title: "头部",
        filename: 'head',
        template: '/head'
    },
    {
        title: "首页",
        filename: 'index',
        template: '/index'
    },
    {
        title: "登录",
        filename: 'login',
        template: '/login'
    },
    {
        title: "关于",
        filename: 'about',
        template: '/about'
    },
    {
        title: "关于子页面",
        filename: 'about-child',
        template: '/about/child'
    },
    {
        title: "3d房子",
        filename: 'three-house',
        template: '/three/house'
    },
    {
        title: "列表",
        filename: 'list',
        template: '/list'
    }
]

let htmlList = []
const dist = `${__dirname}/dist`
const pagePath = './src/pages'

pageList.forEach((page) => {
    const {title, filename, template} = page
    console.log(title, filename, template)
    htmlList.push(new HtmlWebpackPlugin({
        title: title,
        filename: `${dist}/${filename}.html`,
        inject: 'body',
        template: `${pagePath}${template}.html`,
        chunks: [filename],
        inlineSource: '.(js|css)$'
    }))
})

module.exports = htmlList